use serde::Deserialize;
pub const NO_SECRET: &'static str ="no secret";
#[derive(Debug, Deserialize)]
pub struct AuthProviderConfig{
    base_url: Option<String>,
    issuer_url: Option<String>,
    client_id: Option<String>,
    redirect_uri: Option<String>,
    client_secret: Option<String>,
    scopes: Option<Vec<String>>,
}



impl AuthProviderConfig{
    pub fn base_url(&self) ->&str{
        self.base_url.as_deref().unwrap_or("http://localhost:3000")
    }
    pub fn issuer_url(&self) -> &str {
        self.issuer_url.as_deref().unwrap_or("http://localhost:8080/realms/master")
    }
    pub fn client_id(&self) -> &str {
        self.client_id.as_deref().unwrap_or("rid-client")
    }
    pub fn redirect_uri(&self) -> &str {
        self.redirect_uri.as_deref().unwrap_or("http://localhost:3100/login/oauth2/code")
    }
    pub fn client_secret(&self) -> &str {
        self.client_secret.as_deref().unwrap_or("no secret")
    }
    pub fn scopes(&self) -> Vec<&str> {
        match &self.scopes{
            None => {vec!["openid"]}
            Some(arr) => arr.iter().map(String::as_str).collect()
        }
    }

}